package com.mengma.controller;

import com.mengma.dao.ProductMapper;
import com.mengma.entity.Product;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("dd/")
public class TestProductController {
    @Autowired
    private ProductMapper productMapper;

    @PostMapping(value = "dd")
    public String test(){
        return "测试成功";
    }
    @GetMapping(value = "testInsert")
    public String TestInsert(){
        Product product=new Product();
        product.setPid("9090");
        product.setPname("我真帅");
        productMapper.insertSelective(product);
        return product.toString();
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "name 注解",
                    dataType = "String", required = true),
            @ApiImplicitParam(name = "sex", value = "sex 注解",
                    dataType = "Integer", required = false,defaultValue = "123")})
    @ApiOperation(value = "创建一只狗")
    @GetMapping(value = "insertTest")
    public String InsertTest(String name,int sex){
        Product product=new Product();
        product.setPid("9093");
        product.setPname("我真帅");
        int i = productMapper.insertTest(product);
        if (i>0){
            return "新增成功";
        }
        return "新增失败";
    }

}
